<template>
	<view class="resume-container">
		<view class="apply-form-content">
			<view class="resume-form mb24">
				<view class="common-title">
					<image class="common-icon" src="https://hxs.dsjhs.com:553/prod-api/profile/baokao.png" mode="">
					</image>
					<text>报考岗位</text>
				</view>
				<view class="resume-form-item">
					<text class="label">招考单位：</text>
					<input class="input-text" v-model="details.employer" disabled="true" type="text"
						placeholder="请填写招考单位">
				</view>
				<view class="resume-form-item">
					<text class="label required">岗位名称：</text>
					<picker :value="stationIndex" mode="selector" :range="details.recruitPositionList"
						range-key="positionName" @change="handleChangeStation">
						<input class="input-text select"
							v-model="details.recruitPositionList[stationIndex].positionName" disabled type="text"
							placeholder="请选择岗位">
					</picker>
				</view>
			</view>
			<view class="resume-form mb24">
				<view class="common-title">
					<image class="common-icon" src="https://hxs.dsjhs.com:553/prod-api/profile/jbxx.png" mode="">
					</image>
					<text>基本信息</text>
				</view>
				<view class="resume-form-item avatar">
					<view class="form-item-label">
						<text class="label">近期一寸电子版登记照片</text>
						<text class="label-tip">照片用于准考证制作，请谨慎上传</text>
					</view>
					<!-- <button class="avatar-wrap" open-type="chooseAvatar" @chooseavatar="uploadAvatar">
						<image v-if="form.userIcon" class="avatar-box" :src="api_host + form.userIcon" mode=""></image>
						<image class="default-avatar" v-else src="https://hxs.dsjhs.com:553/prod-api/profile/upload.png"
							mode=""></image>
					</button> -->
					<view class="avatar-wrap" v-if="form.userIcon" @tap="uploadAvatar">
						<image class="avatar-box" :src="api_host + form.userIcon" mode=""></image>
					</view>
					
					<view class="avatar-wrap" v-else @tap="uploadAvatar">
						<view class="default-avatar"></view>
					</view>
					

				</view>
				<view class="resume-form-item">
					<text class="label required">姓名</text>
					<input class="input-text" v-model="form.fullName" type="text" placeholder="请填写您的姓名">
				</view>
				<view class="resume-form-item">
					<text class="label required">性别</text>
					<picker :value="form.gender" :range="genderList" @change="handleChangeGender">
						<input class="input-text select" v-model="genderList[form.gender]" disabled type="text" readonly
							placeholder="请选择您的性别">
					</picker>
				</view>
				<view class="resume-form-item">
					<text class="label required">出生年月日</text>
					<picker mode="date" :value="form.dateBirth" fields="day" :start="startDate" :end="endDate"
						@change="handleChangeBirthDay">
						<input class="input-text select" v-model="form.dateBirth" disabled type="text"
							placeholder="请选择您的出生年月">
					</picker>
				</view>
				<view class="resume-form-item">
					<text class="label required">民族</text>
					<input class="input-text" v-model="form.nationality" type="text" placeholder="请填写您的民族">
				</view>
				<view class="resume-form-item">
					<text class="label required">籍贯</text>
					<input class="input-text" v-model="form.nativePlace" type="text" placeholder="请填写您的籍贯">
				</view>
				<view class="resume-form-item">
					<text class="label required">出生地</text>
					<input class="input-text" v-model="form.birthplace" type="text" placeholder="请填写您的出生地">
				</view>
				<view class="resume-form-item">
					<text class="label">入党时间</text>
					<picker mode="date" :value="form.joinParty" fields="day" :start="startDate" :end="endDate"
						@change="handleChangeJoinParty">
						<input class="input-text select" v-model="form.joinParty" disabled type="text"
							placeholder="请选择您的入党时间">
					</picker>
				</view>

				<view class="resume-form-item">
					<text class="label required">参加工作时间</text>
					<picker mode="date" :value="form.timeWork" fields="day" :start="startDate" :end="endDate"
						@change="handleChangeWorkDay">
						<input class="input-text select" v-model="form.timeWork" disabled type="text"
							placeholder="请选择您的参加工作时间">
					</picker>
				</view>
				<view class="resume-form-item">
					<text class="label required">健康状况</text>
					<input class="input-text" v-model="form.healthStatus" type="text" placeholder="请填写您的健康状况">
				</view>
				<view class="resume-form-item">
					<text class="label required">身份证号</text>
					<input class="input-text" v-model="form.idCard" type="text" placeholder="请填写您的身份证号">
				</view>
				<view class="resume-form-item">
					<text class="label">职称或职业资格</text>
					<input class="input-text" v-model="form.academicTitle" type="text" placeholder="请填写职称或职业资格">
				</view>
				<view class="resume-form-item">
					<text class="label required">全日制教育</text>
					<picker :value="schoolIndex" :range="fulltimeSchoolList" @change="handleChangeSchool">
						<input class="input-text select" v-model="fulltimeSchoolList[schoolIndex]" disabled type="text"
							readonly placeholder="请选择全日制教育">
					</picker>
				</view>

				<view class="resume-form-item">
					<text class="label required">毕业院校系及专业</text>
					<input class="input-text" v-model="form.fullalmaMater" type="text" placeholder="请填写毕业院校系及专业">
				</view>

				<view class="resume-form-item">
					<text class="label">在职教育</text>
					<picker :value="inserviceEduIndex" :range="inserviceEduList" @change="handleChangeEdu">
						<input class="input-text select" v-model="inserviceEduList[inserviceEduIndex]" disabled
							type="text" readonly placeholder="请选择在职教育">
					</picker>
				</view>

				<view class="resume-form-item">
					<text class="label required">现单位及职位</text>
					<input class="input-text" v-model="form.currentPosition" type="text" placeholder="请填写您的现单位及职位">
				</view>
				<view class="resume-form-item">
					<text class="label required">联系方式</text>
					<input class="input-text" v-model="form.contactInformation" type="text" placeholder="请填写您的联系方式">
				</view>

				<view class="resume-form-item">
					<text class="label">证明材料(学历证或工作证)</text>
					<view class="input-text select" id="uploadBox" @click="chooseFile" style="width: 70%;">
						<view class="file-box" v-if="fileList.length">
							<text class="ellipsis"
								style="margin-right: 8px;font-size: 28rpx;line-height: 24px;">{{ fileList[0].name }}</text>
							<u-icon name="trash" color="#2979ff" size="24" @click.stop="delFile"></u-icon>
						</view>
					</view>
				</view>

			</view>

			<view class="resume-form mb24">
				<view class="common-title">
					<image class="common-icon" src="https://hxs.dsjhs.com:553/prod-api/profile/jl.png" mode=""></image>
					<text>简历</text>
				</view>
				<view class="resume-form-item introduct">
					<text class="label required">简历</text>
					<editor id="editor" class="textarea-text" style="height: 320px;" placeholder="请填写您的简历..."
						@input="handleChangeText" @ready="onEditorReady"></editor>
				</view>
				<view class="resume-form-item introduct">
					<text class="label">奖惩情况</text>
					<textarea class="textarea-text mt20" v-model="form.rewardSituation" :maxlength="maxLength"
						placeholder="据实填写" />
				</view>
				<view class="resume-form-item introduct">
					<text class="label">年度考核结果</text>
					<textarea class="textarea-text mt20" v-model="form.annualResults" :maxlength="maxLength"
						placeholder="据实填写" />
				</view>
				<view class="resume-form-item introduct">
					<view class="experience-head">
						<text class="label required">家庭主要成员及重要社会关系</text>
						<view class="add-btn" @click="open"></view>
					</view>
					<view class="experience-list" v-if="familyMemberList.length">
						<view class="experience-item" v-for="(item, index) in familyMemberList" :key="index">
							<text class="company-name">{{ item}}</text>
							<image class="close-icon" src="https://hxs.dsjhs.com:553/prod-api/profile/close-icon.png"
								mode="" @tap="handleDeleteMember(index)"></image>
						</view>
					</view>
				</view>
			</view>

			<view class="f24 tip-text">
				<u-checkbox-group @change="handleChecked">
					<u-checkbox v-model="checked" shape="circle"></u-checkbox>
				</u-checkbox-group>
				<text
					style="color: #34314F;font-size: 26rpx;">本人承诺所提供的一切信息、资料真实有效，我已仔细阅读本次招聘公告，清楚并理解其内容。在此我郑重承诺:一、自觉遵守本次招聘工作的有关规定;真实、准确地提供本人个人信息、证明资料、证件等相关材料；三、认真履行报考人员的各项义务;四、遵守报名、考试、体检、考察、试用等工作纪律，服从招聘方工作安排，不舞弊或协助他人舞弊;五、对违反以上承诺所造成的后果，本人自愿承担相应责任。</text>
			</view>

			<view class="submit-btn">
				<button class="save-btn" @tap="handleSave">保存</button>
				<button class="apply-btn" @tap="handleConfirm">提交报名</button>
			</view>
			<!-- 二次弹窗 -->
			<comfirmLayer :showDialog="showConfirmLayer" :resumeStatus="resumeStatus" @close="showConfirmLayer = false"
				@submit="handleSubmit"></comfirmLayer>
			<!-- 等待审核 -->
			<waitlayer :showDialog="showWaitLayer" @close="showWaitLayer = false" @submit="handleReview"></waitlayer>
		</view>
		<!-- 家庭成员 -->
		<popup-layer ref="popupRef" direction="top" class="popup-content">
			<view class="popup-content-wrap">
				<view class="member-form">
					<view class="member-form-item">
						<text class="label required">称谓</text>
						<input class="input-text" v-model="memberForm.relationship" type="text" placeholder="请填写称谓">
					</view>
					<view class="member-form-item">
						<text class="label required">姓名</text>
						<input class="input-text" v-model="memberForm.name" type="text" placeholder="请填写姓名">
					</view>
					<view class="member-form-item">
						<text class="label required">年龄</text>
						<input class="input-text" v-model="memberForm.age" type="text" placeholder="请填写年龄">
					</view>
					<view class="member-form-item">
						<text class="label required">政治面貌</text>
						<input class="input-text" v-model="memberForm.political" type="text" placeholder="请填写政治面貌">
					</view>
					<view class="member-form-item">
						<text class="label required">工作单位及职务</text>
						<input class="input-text" v-model="memberForm.work" type="text" placeholder="请填写工作单位及职务">
					</view>
				</view>

				<view class="popup-footer">
					<button class="reset-btn" @tap="handleCancel">取消</button>
					<button class="add-btn" @tap="handleAddMember">确定</button>
				</view>
			</view>
		</popup-layer>
		<!-- <familymemberpopup ref="familymember"></familymemberpopup> -->
	</view>
</template>

<script>
	import {
		addResume,
		getResume,
		dictionary,
		updateResume
	} from '@/common/api_employment.js'

	import {
		getRecruit,
		applyExamine,
		enrollDetail
	} from '@/common/api_examine.js'
	
	import appInfo from '@/common/appInfo.js'
	import familymemberpopup from './familymemberpopup.vue'
	import comfirmLayer from './comfirmlayer.vue'
	import waitlayer from './waitlayer.vue'
	import popupLayer from '@/components/popupLayer/index.vue'

	export default {
		components: {
			waitlayer,
			popupLayer,
			comfirmLayer,
			familymemberpopup
		},
		data() {
			return {
				details: {},
				showConfirmLayer: false,
				showWaitLayer: false,
				resumeStatus: 300,
				fileList: [],
				imgList: [],
				form: {
					recId: '',
					positionId: '',
					userIcon: '',
					fullName: '',
					gender: '',
					dateBirth: '',
					nationality: '',
					nativePlace: '',
					birthplace: '',
					joinParty: '',
					timeWork: '',
					healthStatus: '',
					idCard: '',
					academicTitle: '',
					fulltimeSchool: '',
					fullalmaMater: '',
					inserviceEducation: '',
					currentPosition: '',
					contactInformation: '',
					resume: '',
					rewardSituation: '',
					annualResults: '',
					familyMembers: '',
					infoStatus: '',
					userEducation: '',
					proofMaterials: ''
				},
				familyMemberList: [],
				stationIndex: -1,
				schoolIndex: -1,
				inserviceEduIndex: -1,
				enrolStartDate: '',
				enrolEndDate: '',
				genderIndex: -1,
				stationEduIndex: -1,
				genderList: ['男', '女'],
				fulltimeSchoolList: ['博士研究生', '硕士研究生', '本科', '大专', '中专（高中）', '初中', '小学'],
				inserviceEduList: ['博士研究生', '硕士研究生', '本科', '大专'],
				maxLength: 1000,
				dicList: [],
				checked: false,
				memberForm: {
					relationship: '',
					name: '',
					age: '',
					political: '',
					work: ''
				},
			}
		},
		computed: {

			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		mounted() {
			this.$refs.popupRef.close()
		},

		onLoad: function(option) {
			this.recId = option.id
			this.getDetails(option.id)
		},

		methods: {
			async getDetails(id) {
				const res = await getRecruit(id)
				if (res.code === 200) {
					this.details = res.data
					this.getPersonInfo(id)
				}
			},
			async getPersonInfo(id) {
				const res = await enrollDetail(id)
				if (res.code === 200) {
					// this.details = res.data
					this.form = res.data
					this.stationIndex = this.details.recruitPositionList.findIndex(item => item.id === this.form
						.positionId)

					this.schoolIndex = this.fulltimeSchoolList.findIndex(item => item === this.form.fulltimeSchool)
					this.inserviceEduIndex = this.inserviceEduList.findIndex(item => item === this.form
						.inserviceEducation)
					if (res.data.familyMembers) {
						this.familyMemberList = res.data.familyMembers.split(',')
					} else {
						this.familyMemberList = []
					}
				}
			},
			open() {
				this.$refs.popupRef.show()
			},
			handleDeleteMember(idx) {
				this.familyMemberList.splice(idx, 1)
			},
			
			// 上传
			async uploadAvatar(e) {
				uni.chooseImage({
					count: 1, // 最多选择9张
					sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图
					sourceType: ['album'], // 可以指定来源是相册还是相机
					success: (res) => {
						console.log(res, 'chooseImage')
						const avatarUrl = res.tempFilePaths[0]
						
						uni.getImageInfo({
							src: avatarUrl,
							success: (res) => {
								let {
									width,
									height,
									orientation
								} = res;
								console.log(res, 'uploadAvatar')
								// 处理旋转导致的宽高颠倒
								if ([6, 8].includes(orientation)) {
									[width, height] = [height, width];
								}
								this.checkImageSize(width, height, avatarUrl);
							},
							fail: (err) => {
								console.error('获取图片信息失败:', err);
							}
						});
					}
				})
			},
			async checkImageSize(width, height, avatarUrl) {
				const TARGET_WIDTH = 295;
				const TARGET_HEIGHT = 413;
				const TOLERANCE = 0.05;
				const TARGET_RATIO = TARGET_WIDTH / TARGET_HEIGHT;

				const isWidthValid = Math.abs(width - TARGET_WIDTH) <= TARGET_WIDTH * TOLERANCE;
				const isHeightValid = Math.abs(height - TARGET_HEIGHT) <= TARGET_HEIGHT * TOLERANCE;
				const isRatioValid = Math.abs((width / height) - TARGET_RATIO) <= TARGET_RATIO * TOLERANCE;

				if ((isWidthValid && isHeightValid) || isRatioValid) {
					uni.showToast({
						title: '上传成功'
					});
					// 处理上传逻辑
					const res = await this.$utils.uploadFile(avatarUrl)
					console.log(res, 'resss')
					if (res.code == 200) {
						this.form.userIcon = res.fileName
					} else {
						this.form.userIcon = ''
					}
				} else {
					uni.showToast({
						title: '照片不符合要求，请上传标准的1寸照片(295x413像素)',
						icon: 'none',
						duration: 3000
					});
				}
			},
			async getDictionary() {
				const dictionaryData = await dictionary()
				this.dicList = dictionaryData.data.filter(item => item.field === 'stationEdu')[0].dicts
				if (this.form.userEducation) {
					this.stationEduIndex = this.findValByKey(this.dicList, this.form.userEducation)
				}
			},
			handleChangeStation(e) {
				console.log(e, 'handleChangeStation')
				this.stationIndex = e.detail.value
				this.form.positionId = this.details.recruitPositionList[this.stationIndex].id
			},
			handleChangeGender(e) {
				this.genderIndex = e.detail.value
				this.form.gender = Number(e.detail.value)
			},
			// handleChangeStationEduIndex(e) {
			// 	console.log(e, 'handleChangeStationEduIndex')
			// 	this.stationEduIndex = e.detail.value
			// 	this.form.userEducation = this.dicList[e.detail.value]
			// },
			handleChangeBirthDay(e) {
				this.form.dateBirth = e.detail.value
			},
			handleChangeJoinParty(e) {
				this.form.joinParty = e.detail.value
			},
			handleChangeSchool(e) {
				this.schoolIndex = e.detail.value
				this.form.fulltimeSchool = this.fulltimeSchoolList[this.schoolIndex]
			},
			handleChangeEdu(e) {
				this.inserviceEduIndex = e.detail.value
				this.form.inserviceEducation = this.inserviceEduList[this.inserviceEduIndex]
			},
			handleChangeWorkDay(e) {
				this.form.timeWork = e.detail.value
			},
			handleChangeEnrolStartDate(e) {
				this.enrolStartDate = e.detail.value
			},
			handleChangeEnrolEndDate(e) {
				this.enrolEndDate = e.detail.value
			},
			handleAddMember() {
				const isValidMember = this.checkMemberForm()
				if (isValidMember) {
					const deepObj = JSON.parse(JSON.stringify(this.memberForm))
					const memberShips =
						`${deepObj.name}/${deepObj.relationship}/${deepObj.age}/${deepObj.political}/${deepObj.work}`
					console.log(this.familyMemberList, ' this.familyMemberList')
					this.familyMemberList.push(memberShips)
					this.$refs.popupRef.close()
					this.resetMemberForm()
				}
			},
			handleCancel() {
				this.resetMemberForm()
				this.$refs.popupRef.close()
			},
			resetMemberForm() {
				for (var key in this.memberForm) {
					if (this.memberForm.hasOwnProperty(key)) {
						this.memberForm[key] = ''
					}
				}
			},
			handleChangeText(e) {
				this.form.resume = e.detail.html
				// this.fontNumber = e.detail.text.length
			},
			onEditorReady() {
				const _this = this
				uni.createSelectorQuery().select('#editor').context((res) => {
					res.context.setContents({
						html: this.form.resume
					})
				}).exec()
			},
			handleChecked(arr) {
				console.log(arr, 'handleChecked')
				this.checked = !!arr.length
			},

			// 从本地选择文件。
			chooseFile(e) {
				console.log(e, 'chooseFile')
				if (e.target.id !== 'uploadBox') {
					return
				}
				uni.chooseMessageFile({
					count: 6, //最多可以选择的文件数量，默认100
					//extension: ['.pdf'], //所选的文件的类型，默认全部
					success: (res) => {
						// 调用上传文件方法
						console.log(res, 'ressss')
						const file = res.tempFiles
						this.uploadFile(file)
					},
					fail: (err) => {
						console.log(err);
					}
				});
			},

			async uploadFile(files) {
				console.log(files, 'files')
				const fileUrl = files[0].path
				const res = await this.$utils.uploadFile(fileUrl)
				if (res.code === 200) {
					this.fileList = files; //fileList需要在data中初始定义为一个数组
					this.form.proofMaterials = res.fileName
					this.form.fileName = files[0].name
				} else {
					this.fileList = []
					this.form.proofMaterials = ''
					this.form.fileName = ''
				}
			},
			// 删除附件
			delFile(index) {
				uni.showModal({
					title: '提示',
					content: '确定删除吗？',
					success: (res) => {
						if (res.confirm) {
							this.fileList = []
							this.form.proofMaterials = ''
							this.form.fileName = ''
						}
					}
				});
			},
			// 保存
			async handleSave() {
				this.form.infoStatus = 0
				this.form.recId = this.recId
				this.form.familyMembers = this.familyMemberList && this.familyMemberList.join(',')
				const res = await applyExamine(this.form)
				if (res.code === 200) {
					uni.showToast({
						title: '保存成功！',
					})
				}
			},

			handleConfirm() {
				const isValid = this.checkForm()
				if (isValid) {
					this.showConfirmLayer = true
				}
			},

			// 开始报名
			async handleSubmit() {
				this.form.infoStatus = 1
				this.form.auditStatus = 1
				this.form.recId = this.recId
				this.form.familyMembers = this.familyMemberList.join(',')
				const res = await applyExamine(this.form)
				if (res.code === 200) {
					this.showConfirmLayer = false
					this.showWaitLayer = true
					uni.showToast({
						title: '报名成功！',
					})
					// #ifdef MP-WEIXIN
					let messageRes = await this.$utils.messageSubscriptionAuthorization(appInfo.tmplIds.examine);
					// #endif
				}

				// if (this.form.idCard) {
				// 	const validCard = this.isValidID(this.form.idCard)
				// 	if (!validCard) {
				// 		uni.showToast({
				// 			title: '身份证格式错误',
				// 			icon: 'error'
				// 		})
				// 		return
				// 	}
				// }
				// if (this.form.contactInformation && !this.$utils.validatePhone(this.form.contactInformation)) {
				// 	uni.showToast({
				// 		title: '手机格式错误',
				// 		icon: 'error'
				// 	})
				// 	return
				// }



				// const requestApi = this.form.id ? updateResume : addResume
				// const resultData = await requestApi(this.form)
				// console.log(resultData, 'resultData')
				// if (resultData.code === 200) {
				// 	uni.showToast({
				// 		title: '保存成功'
				// 	})
				// 	setTimeout(() => {
				// 		uni.navigateTo({
				// 			url: '/subpage/talentemployment/employment/index'
				// 		})
				// 	}, 300)
				// }
			},
			// 校验表单
			checkForm() {
				if (!this.form.positionId) {
					uni.showToast({
						title: '请填写岗位名称',
						icon: 'none'
					})
					return false
				}

				if (!this.form.userIcon) {
					uni.showToast({
						title: '请上传1寸照片',
						icon: 'none'
					})
					return false
				}

				if (!this.form.fullName) {
					uni.showToast({
						title: '请填写姓名',
						icon: 'none'
					})
					return false
				}

				if (this.form.gender != 0 && this.form.gender != 1) {
					uni.showToast({
						title: '请选择性别',
						icon: 'none'
					})
					return false
				}


				if (!this.form.dateBirth) {
					uni.showToast({
						title: '请选择出生年月日',
						icon: 'none'
					})
					return false
				}

				if (!this.form.nationality) {
					uni.showToast({
						title: '请填写民族',
						icon: 'none'
					})
					return false
				}

				if (!this.form.nativePlace) {
					uni.showToast({
						title: '请填写籍贯',
						icon: 'none'
					})
					return false
				}

				if (!this.form.birthplace) {
					uni.showToast({
						title: '请填写出生地',
						icon: 'none'
					})
					return false
				}

				if (!this.form.timeWork) {
					uni.showToast({
						title: '请选择参加工作时间',
						icon: 'none'
					})
					return false
				}

				if (!this.form.healthStatus) {
					uni.showToast({
						title: '请填写健康状态',
						icon: 'none'
					})
					return false
				}

				if (!this.form.idCard) {
					uni.showToast({
						title: '请填写身份证号码',
						icon: 'none'
					})
					return false
				}

				if (!this.form.fulltimeSchool) {
					uni.showToast({
						title: '请选择全日制教育',
						icon: 'none'
					})
					return false
				}

				if (!this.form.fullalmaMater) {
					uni.showToast({
						title: '请填写毕业院校系及专业',
						icon: 'none'
					})
					return false
				}

				if (!this.form.currentPosition) {
					uni.showToast({
						title: '请填写现单位及职位',
						icon: 'none'
					})
					return false
				}

				if (!this.form.contactInformation) {
					uni.showToast({
						title: '请填写联系方式',
						icon: 'none'
					})
					return false
				}

				if (!this.form.resume) {
					uni.showToast({
						title: '请填写简历',
						icon: 'none'
					})
					return false
				}

				if (!this.familyMemberList.length) {
					uni.showToast({
						title: '请添加家庭主要成员及重要社会关系',
						icon: 'none'
					})
					return false
				}

				if (!this.checked) {
					uni.showToast({
						title: '请阅读并勾选',
						icon: 'none'
					})
					return false
				}

				return true
			},

			// 校验家庭成员表单
			checkMemberForm() {
				if (!this.memberForm.relationship) {
					uni.showToast({
						title: '请填写称谓',
						icon: 'none'
					})
					return false
				}

				if (!this.memberForm.name) {
					uni.showToast({
						title: '请填写姓名',
						icon: 'none'
					})
					return false
				}

				if (!this.memberForm.age) {
					uni.showToast({
						title: '请填写年龄',
						icon: 'none'
					})
					return false
				}

				if (!this.memberForm.political) {
					uni.showToast({
						title: '请填写政治面貌',
						icon: 'none'
					})
					return false
				}
				if (!this.memberForm.work) {
					uni.showToast({
						title: '请填写工作单位及职位',
						icon: 'none'
					})
					return false
				}
				return true
			},

			// 去看看
			handleReview() {
				uni.navigateTo({
					url: '/subpage/examine/myexamine'
				})
			},
			// 请求简历数据
			async getResumeData() {

			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			isObjectEmpty(obj) {
				return Object.keys(obj).length === 0;
			},
			findValByKey(arr, val) {
				return arr.findIndex(item => item === val)
			},
			// 身份证校验
			isValidID(id) {
				var pattern = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/;
				return pattern.test(id);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.resume-container {
		width: 100%;
		// padding: 24rpx 32rpx 40rpx 32rpx;
		background: #F2F5FF;
		box-sizing: border-box;

		.apply-form-content {
			width: 100%;
			padding: 24rpx 32rpx 40rpx 32rpx;
			box-sizing: border-box;
		}
	}

	.resume-form {
		width: 100%;
		padding: 40rpx 46rpx 36rpx;
		background: #FFFFFF;
		border-radius: 20px;
		box-sizing: border-box;

		.common-title {
			display: flex;

			.common-icon {
				width: 40rpx;
				height: 40rpx;
			}

			text {
				display: block;
				margin-left: 12rpx;
				font-weight: 600;
				font-size: 32rpx;
				color: #34314F;
				line-height: 44rpx;
				text-align: left;
				font-style: normal;
			}
		}

		.resume-form-item {
			display: flex;
			justify-content: space-between;
			padding: 32rpx 0;
			border-bottom: 2rpx solid rgba(52, 49, 79, 0.08);

			&.avatar {
				padding: 20rpx 0;
			}

			.file-box {
				display: flex;
				justify-content: flex-end;
			}

			&.introduct {
				display: block;
				position: relative;
				border-bottom: 0;
				padding: 32rpx 0 0;
			}

			.avatar-wrap {
				position: relative;
				display: block;
				width: 112rpx;
				height: 112rpx;
				margin: 0;
				padding: 0;
				border-radius: 50%;
				background: #ECEDF0;
				overflow: hidden;

				.avatar-box {
					width: 112rpx;
					height: 112rpx;
				}

				.default-avatar {
					position: absolute;
					width: 40rpx;
					height: 40rpx;
					left: 50%;
					bottom: 16rpx;
					transform: translateX(-50%);
					background: url('https://hxs.dsjhs.com:553/prod-api/profile/upload.png') no-repeat center;
					background-size: cover;
				}

				&::after {
					border: 0;
				}
			}

			.label {
				position: relative;
				display: block;
				min-width: 70px;
				font-weight: 400;
				font-size: 28rpx;
				color: #34314F;
				line-height: 20px;

				&.required {
					padding-left: 14rpx;

					&::after {
						position: absolute;
						content: '*';
						left: 0;
						top: 0;
						color: red;
					}
				}
			}

			.label-tip {
				font-weight: 400;
				font-size: 26rpx;
				color: rgba(52, 49, 79, 0.7);
				line-height: 18px;
				text-align: left;
			}

			.input-text {
				position: relative;
				text-align: right;
				font-size: 26rpx;

				&.select {
					padding-right: 40rpx;
				}

				&.select::after {
					position: absolute;
					top: 50%;
					right: 0;
					display: block;
					width: 32rpx;
					height: 32rpx;
					transform: translateY(-50%);
					background: url('@/static/images/index/right-arrow.png') no-repeat center;
					background-size: 100% 100%;
					content: '';
				}
			}

			.textarea-text {
				width: 100%;
				height: 440rpx;
				padding: 24rpx 20rpx;
				box-sizing: border-box;
				font-size: 26rpx;
				border: 1px solid rgba(52, 49, 79, 0.08);
				border-radius: 16rpx;
			}

			.count {
				position: absolute;
				bottom: 16rpx;
				right: 20rpx;
				font-size: 24rpx;
				color: rgba(52, 49, 79, 0.4);
			}

			.experience-head {
				display: flex;
				justify-content: space-between;

			}

			.experience-list {
				margin-top: 40rpx;

				.experience-item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 10rpx;
					padding-bottom: 10rpx;
					border-bottom: 2rpx solid rgba(52, 49, 79, 0.08);

					&:last-child {
						margin-bottom: 0;
					}

					.company-name {
						display: block;
						margin-bottom: 14rpx;
						font-weight: 600;
						font-size: 26rpx;
						color: #34314F;
						line-height: 44rpx;
						text-align: left;
					}

					.close-icon {
						width: 32rpx;
						height: 32rpx;
					}

					.job-name {
						font-weight: 600;
						font-size: 26rpx;
						color: #34314F;
						line-height: 44rpx;
						text-align: left;
					}

					.work-date {
						margin-left: 28rpx;
						font-weight: 400;
						font-size: 26rpx;
						color: rgba(52, 49, 79, 0.5);
						line-height: 32rpx;
						text-align: center;
						font-style: normal;
					}

					.work-desc {
						position: relative;
						display: block;
						margin-top: 20rpx;
						font-weight: 400;
						font-size: 26rpx;
						color: rgba(52, 49, 79, 0.7);
						line-height: 44rpx;
						text-align: left;
						font-style: normal;

						&::after {
							position: absolute;
							top: 50%;
							right: -36rpx;
							display: block;
							width: 32rpx;
							height: 32rpx;
							transform: translateY(-50%);
							background: url('@/static/images/index/right-arrow.png') no-repeat center;
							background-size: 100% 100%;
							content: '';
						}
					}
				}
			}

			.add-btn {
				width: 40rpx;
				height: 40rpx;
				background: url('@/static/images/more.png') no-repeat center;
				background-size: 100% 100%;
			}
		}
	}

	.tip-text {
		display: flex;
		align-items: baseline;
	}

	.submit-btn {
		display: flex;
		margin-top: 44rpx;

		.save-btn {
			width: 268rpx;
			height: 48px;
			margin-right: 28rpx;
			font-weight: 600;
			font-size: 32rpx;
			color: #fff;
			line-height: 48px;
			text-align: center;
			font-style: normal;
			background: #34314F;
			border-radius: 20px;

			&::after {
				border: 0;
			}
		}

		.apply-btn {
			width: 408rpx;
			height: 48px;
			font-weight: 600;
			font-size: 32rpx;
			color: #34314F;
			line-height: 48px;
			text-align: center;
			font-style: normal;
			background: #FFDE6D;
			border-radius: 20px;

			&::after {
				border: 0;
			}
		}
	}

	.ellipsis {
		white-space: nowrap;
		/* 不换行 */
		overflow: hidden;
		/* 隐藏超出的内容 */
		text-overflow: ellipsis;
		/* 用省略号表示被隐藏的部分 */
		max-width: 300rpx;
		/* 设置最大宽度以限制文本的显示长度 */
	}

	.popup-content {
		width: 100%;
		height: 600px;
		border-radius: 20px;
		padding: 50rpx 32rpx 40rpx 32rpx;
		box-sizing: border-box;
		overflow-y: auto;

		.popup-content-wrap {
			// position: fixed;
			height: 100%;
			overflow-y: auto;
			width: 100%;
			box-sizing: border-box;
		}

		.member-form {
			width: 100%;
			padding: 18rpx 46rpx 36rpx;
			background: #FFFFFF;
			border-radius: 20px;
			box-sizing: border-box;

			.member-form-item {
				display: flex;
				justify-content: space-between;
				padding: 32rpx 0;
				border-bottom: 2rpx solid rgba(52, 49, 79, 0.08);

				&.introduct {
					display: block;
					position: relative;
				}


				.label {
					position: relative;
					display: block;
					font-weight: 400;
					font-size: 28rpx;
					color: #34314F;
					line-height: 20px;

					&.required {
						padding-left: 14rpx;

						&::after {
							position: absolute;
							content: '*';
							left: 0;
							top: 0;
							color: red;
						}
					}
				}


				.label-tip {
					font-weight: 400;
					font-size: 26rpx;
					color: rgba(52, 49, 79, 0.7);
					line-height: 18px;
					text-align: left;
				}

				.input-text {
					position: relative;
					text-align: right;
					font-size: 26rpx;

					&.select {
						padding-right: 40rpx;
					}

					&.select::after {
						position: absolute;
						top: 50%;
						right: 0;
						display: block;
						width: 32rpx;
						height: 32rpx;
						transform: translateY(-50%);
						background: url('@/static/images/index/right-arrow.png') no-repeat center;
						background-size: 100% 100%;
						content: '';
					}
				}

				.textarea-text {
					width: 100%;
					height: 440rpx;
					padding: 24rpx 0;
					box-sizing: border-box;
					font-size: 26rpx;
				}

				.count {
					position: absolute;
					bottom: 16rpx;
					right: 20rpx;
					font-size: 24rpx;
					color: rgba(52, 49, 79, 0.4);
				}

				.add-btn {
					width: 40rpx;
					height: 40rpx;
					background: url('@/static/images/more.png') no-repeat center;
					background-size: 100% 100%;
				}
			}

		}



		.popup-footer {
			width: 100%;
			display: flex;
			padding-bottom: 40rpx;
			background-color: #fff;
			justify-content: space-around;
			align-items: center;

			.reset-btn {
				margin-right: 32rpx;
				background-color: rgba(52, 49, 79, 0.06);
			}

			.add-btn {
				text-align: center;
				background-color: rgba(255, 222, 109, 1);
			}

			button {
				width: 268rpx;
				height: 96rpx;
				border-radius: 40rpx;
				font-weight: 600;
				font-size: 32rpx;
				color: #34314F;
				line-height: 96rpx;
				text-align: center;
				margin: 0;

				&::after {
					border: 0;
				}
			}
		}
	}
</style>